<template>
  <yy-sign ref="signRef" @signed="onSigned" style="width: 100%;height: 100%;"></yy-sign>
</template>

<script>
  import {
	  getOptionsParams,
    navBack,
    uploadFile
  } from '../utils/util';
  export default {
    data() {
      return {
        signRef: null,
		routerParams: {}
      }
    },
	onLoad(options) {
		this.routerParams = getOptionsParams(options)
	},
    methods: {
      async onSigned(data) {
        // 成功了就上传文件
        try {
          let uploadRes = await uploadFile({
            url: "/web/sys/upload/upload_file",
            filePath: data.tempFilePath,
            name: "file",
            formData: {
              type: 21,
            },
          })
          let {
            fullPath,
            halfPath
          } = uploadRes.result;
		  // 判断是 从合格来的还是不合格
		  if(this.routerParams.source === 'no-pass') {
			  uni.$emit('signed', {
				  ...uploadRes.result,
				  status: 'noPass'
			  })
		  } else {
			  uni.$emit('signed', uploadRes.result)
			  navBack()
		  }
        } finally {

        }
      }
    }
  }
</script>

<style>
  page {
    width: 100%;
    height: 100%;
  }
</style>